<div class="container-fluid" style="margin-top: 10px;">
    <div class="row">

        <div class="col-sm-12">
            <label>变动图书</label>
            <table class="table table-bordered">
                <thead>
                <tr>
                    <th>图书编号</th>
                    <th>图书名称</th>
                    <th>隶属单位</th>
                    <th>数量</th>
                    <th>价值</th>
                    <th>当前状态</th>
                </tr>
                </thead>
                <tbody>
                {volist name='bookList' id='vo'}
                <tr>
                    <td>{$vo.BOOK_NO}</td>
                    <td>{$vo.BOOK_NAME}</td>
                    <td>{$vo.BELONG}</td>
                    <td>{$vo.BOOK_NUM}</td>
                    <td>{$vo.BOOK_FEE}</td>
                    <td>{$vo.STATUS}</td>
                </tr>
                {/volist}
                </tbody>
            </table>
        </div>

        <div class="col-sm-12">
            <label>变动表单</label>
            <div class="col-sm-12" style="border: 1px solid #ddd;padding: 10px 0px">
                <form id="alterForm" method="post" action="addAlter">
                    <input hidden name="bookIds" value="{$bookIds}">
                    {:form('text',['title'=>'变动类型','value'=>'报废','disable'=>'disabled'])}
                    {:line()}
                    {:form('text',['title'=>'变动数量','name'=>'ALTER_NUM'])}
                    {:form('text',['title'=>'变动价值','name'=>'ALTER_VALUE'])}
                    {:form('text',['title'=>'变动日期','name'=>'ALTER_DATE'])}
                    {:form('text',['title'=>'批准单位','name'=>'PASS_DEPART'])}
                    {:form('text',['title'=>'批准文号','name'=>'PASS_NO'])}
                    {:form('text',['title'=>'批准人','name'=>'PASS_PERSON'])}
                    {:form('text',['title'=>'收购单位','name'=>'RELEVANT_DEPART'])}
                    {:form('text',['title'=>'处置收益','name'=>'ALL_FEE'])}
                    {:form('text',['title'=>'经手人','name'=>'WORK_PERSON'])}
                    {:form('text',['title'=>'备注','name'=>'REMARK','col'=>'col-sm-12'])}
                    {:line()}
                    {:form('text',['title'=>'制单人','disable'=>'disabled','value'=>$Think.session.user_name])}
                    {:form('text',['title'=>'制单时间','disable'=>'disabled','value'=>date('Y-m-d')])}
                </form>
            </div>
        </div>

        <div class="col-sm-12" style="margin-top: 10px;text-align: center">
            <button id="submit" class="btn btn-info">确认变更</button>
        </div>
    </div>
</div>

<script>

    $(function () {

        $("[name='ALTER_DATE']").flatpickr();

        $("#submit").on('click',function () {
            layer.confirm('确认执行变更吗？',function (index) {
                layer.close(index);
                layer.load();
                $("#alterForm").ajaxSubmit(function (text) {
                    console.log(text);
                    layer.closeAll('loading');
                    var json = JSON.parse(text);
                    if(json['code']=='200'){
                        layer.alert(json['msg'],{icon:1},function (index) {
                            layer.close(index);
                            parent.location.reload();
                        });
                    }
                    else{
                        layer.alert(json['msg'],{icon:2});
                    }
                });
            });
        });
    });


</script>